package cn.hp.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.hp.domain.User;
import cn.hp.mapper.UserMapper;
@Service
@Transactional  //springboot默认开启事务支持
public class UserServiceImpl implements UserService {
	
	@Autowired
	private UserMapper userMapper;
	

	@Override
	public User findUserById(int id) {
		// TODO Auto-generated method stub
		return userMapper.findUserById(id);
	}

	@Override
	public List<User> findAll() {
		// TODO Auto-generated method stub
		return userMapper.findAll();
	}

	@Override
	public void delete(int id) {
		userMapper.delete(id);
		//如果代码报错应该进行事务回滚，不应该删除这条数据
		int i = 10/0;
	}

}
